package ua.kpi_java_training.tyshchenko.module2;

/**
 * Class contains statistics:
 * amount new fishes, star amount fishes, amount killed fishes
 *
 * @author Vlad Tyshchenko
 * @version 1.1 3 June 2013
 */
public class Statistics {
    private int amountChildrenVictims;
    private int amountKilledVictims;
    private int amountChildrenPredators;
    private int startAmountVictim;
    private int startAmountPredator;

    /**
     * @param startAmountVictim   - initial number of victims
     * @param startAmountPredator - - initial number of predators
     */
    public Statistics(int startAmountVictim, int startAmountPredator) {
        this.startAmountVictim = startAmountVictim;
        this.startAmountPredator = startAmountPredator;
        amountChildrenPredators = 0;
        amountChildrenVictims = 0;
        amountKilledVictims = 0;
    }

    public void addChildren(KindOfCreatures creature) {
        switch (creature) {
            case victim:
                amountChildrenVictims++;
                break;
            case predator:
                amountChildrenPredators++;
                break;
            default:
                System.out.println("Wrong type of creature ");
        }
    }

    public void addKilledVictim() {
        amountKilledVictims++;
    }

    public int getAmountVictimEnd() {
        return startAmountVictim + amountChildrenVictims - amountKilledVictims;
    }

    public int getAmountPredatorEnd() {
        return startAmountPredator + amountChildrenPredators;
    }

    public int getAmountChildrenVictims() {
        return amountChildrenVictims;
    }

    public int getAmountChildrenPredators() {
        return amountChildrenPredators;
    }

    /**
     * @return all statistics
     */
    public String toString() {
        return String.format("Amount victims in habitat: %d \nAmount predators in habitat: %d \n" +
                "Amount killed victims %d \nAmount born victims %d \nAmount born predators %d \n",
                getAmountVictimEnd(), getAmountPredatorEnd(), amountKilledVictims,
                amountChildrenVictims, amountChildrenPredators);
    }

}
